package com.littleII.dao.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.littleII.dao.BaseDAO;

public class BaseDAOImpl extends HibernateDaoSupport implements BaseDAO{
	public void save(Object o) {
		this.getSession().save(o);
	}
	public void saveOrUpdate(Object o){
		this.getSession().saveOrUpdate(o);
	}
	public void delete(Object o){
		this.getSession().delete(o);
	}
	public void update(Object o){
		this.getSession().update(o);
	}
	@SuppressWarnings("unchecked")
	public <T extends Serializable> List<T> getObjList(String hql,Map<String,Object> map) {
		return (List<T>) this.getSession().createQuery(hql).setProperties(map).list();
	}
	@SuppressWarnings("unchecked")
	public <T extends Serializable> T getObj(String hql,Map<String,Object> map) {
		return (T) this.getSession().createQuery(hql).setProperties(map).list().get(0);
	}
}
